<table>
  <tr>
    <th>Name</th>
    <th>Owner</th>
    <th>Creator</th>
    <th>Type</th>
    <th>Duration</th>
    <th>Start</th>
    <th>End</th>
    <th>Approved</th>
    <% if @current_user.administrator %>
      <th>Edit</th>

      <% if defined?(show_approve) %>
        <th>Approve</th>
      <% end %>
    <% end %>
  </tr>

<% events.each do |event| %>
  <tr>
    <td><%= link_to event.name, event %></td>
    <td><%= link_to event.owner.username, event.owner %></td>
    <td><%= link_to event.creator.username, event.creator %></td>
    <td><%= Event::TYPE_NAMES[event.event_type] %></td>
    <% if event.duration_type == Event::MULTI_DAY %>
      <td><%= pluralize(event.duration, 'days')%></td>
    <% else %>
      <td><%= Event::DURATION_NAMES[event.duration_type] %></td>
    <% end %>
    <td><%= event.start_at.to_formatted_s(:short) %></td>
    <td><%= event.end_at.to_formatted_s(:short) %></td>
    <td><%  display_true_false_field(event.approved) %></td>
    <% if @current_user.administrator %>
      <td><%= link_to 'Edit', edit_event_path(event) %></td>
      <% if defined?(show_approve) %>
        <td><%= link_to 'Approve', approve_event_path(event) %></td>
      <% end %>
    <% end %>
  </tr>
<% end %>
</table>

